// 引入mysql模块
const mysql = require("mysql");

// 实例化数据库连接对象
var connect = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "root",
  database: "supermarket",
});

// 连接数据库
connect.connect(function (err) {
  if (err) {
    console.log("连接失败");
  } else {
    console.log("连接成功");
  }
});

// 导出数据库连接对象
module.exports = connect;
